import java.io.*;

public class FIle1 {

    public static void main(String args[]){
        /*使用file类练习
        File f=new File("src\\File1.java");
        boolean read=f.canRead();
        String path=f.getPath();
        String apath=f.getAbsolutePath();
        System.out.println(path);
        System.out.println(apath);
        System.out.print(read);

        File f2=new File("new.txt");
        if(!f2.exists()){
            try {
                f2.createNewFile();
            } catch (IOException e) {
                System.out.println("这里出现异常了。" );
                throw new RuntimeException(e);
            }
        }*/
        /*文件字节输入输出流
        try {
            byte[] b=new byte[100];
            FileInputStream fis=new FileInputStream("new.txt");
            fis.read(b);
            String s=new String(b,0,100);
            System.out.println(s);
        } catch (FileNotFoundException e) {
            System.out.println("这里出现异常了。" );
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
         */
        int numpersion=0;
        int injected=0;
        int notinjected=0;
    File fread=new File("new.txt");
    File result=new File("result.txt");
        try {
            Reader in=new FileReader(fread);
            BufferedReader br=new BufferedReader(in);
            String str=null;
            while((str=br.readLine())!=null){
                numpersion++;
                String[] strarray=str.split(" ");
               // System.out.println(strarray[0]);
                if("Y".equals(strarray[1])){
                    injected++;
                }else if("N".equals(strarray[1])){
                    notinjected++;
                }
            }
            System.out.println(numpersion);
            System.out.println("接种的有"+injected);
            System.out.println("没接种的有"+notinjected);

        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        try {
            result.createNewFile();
            Writer out=new FileWriter(result);
            BufferedWriter bw=new BufferedWriter(out);
            String firstLine="一共有"+numpersion;
            bw.write(firstLine);
            bw.newLine();
            bw.write(String.valueOf(injected));
            bw.newLine();
            bw.write(String.valueOf(notinjected));
            bw.close();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }


    }

}
